﻿<%@ Page Language="C#" MasterPageFile="~/Masters/Basic.Master" AutoEventWireup="true" CodeBehind="BottleCommissionList.aspx.cs" Inherits="PMS.UI.PM.BottleCommissionList" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        $(function () {
            var height = $("#divTotal").height();
            var master = $("#master").height();
            var content = parseFloat(height) - parseFloat(master) - 30;
            $("#tbList").css("height", content);
        });
    </script>
    <script type="text/javascript">
        $(function () {
            //   $('#btnModify').linkbutton('disable');
            $("#tbList").datagrid({
                url: '/Logic/PM/ProductOrderAjax.aspx?method=GetBottleCommissionList',
                loadMsg: '数据加载中请稍后……',
                fitColumns: false,
                pagination: true,
                queryParams: com.serializeSearchArray("form1"),
                rownumbers: true,
                idField: "QuotationDetailID",
                singleSelect: true,
                pageSize: 20,
                pageList: [20, 50, 100],
                striped: true,
                remoteSort: false,
                frozenColumns: [[{ field: 'ck', checkbox: true, width: 30 },
                     {
                         field: 'IsComplete', title: '是否完成', align: "center", width: 60,
                         formatter: function (value, row, Index) {
                             return com.getArrayText([{ value: "0", text: "未完成" }, { value: "1", text: "已完成" }], value);
                         },
                         styler: function (value, row, index) {
                             if (value == "1") {
                                 return 'background-color:#00EC00;color:black';
                             }
                         }
                     },
                 {
                     field: 'IsUrgent', title: '是否紧急', align: "center", width: 60,
                     formatter: function (value, row, Index) {
                         return com.getArrayText(StaticCombo.isOrderUrgent, value);
                     },
                     styler: function (value, row, index) {
                         if (value == "1") {
                             return 'color:red';
                         }
                     }
                 },

                {
                    field: 'ProductOrderCode', title: '生产订单号 ', align: "center", width: 100
                },
                 {
                     field: 'ComName', title: '客户单位名称', align: "center", width: 100
                 }, {
                     field: 'OrderDate', title: '下单日期', align: "center", width: 80
                 },
                 {
                     field: 'ReleaseDate', title: '交货日期', align: "center", width: 80
                 },
                ]],
                columns: [[

                  {
                      field: 'ProductName', title: '产品名称', sortable: true, align: "center", width: 100,
                      formatter: function (value, row, index) {
                          //鼠标放在文本处自动显示tooltip
                          return '<span title=' + value + '>' + value + '</span>';
                      }
                  },
                  {
                      field: 'TechParams', title: '技术参数', align: "center", width: 200, sortable: true,
                      formatter: function (value, row, index) {
                          //鼠标放在文本处自动显示tooltip
                          return '<span title=' + value + '>' + value + '</span>';
                      },
                      sorter: function (a, b) {
                          //相同组分可按浓度高低排序
                          //a=SO2:1000ppm;N2:10ppm   b=SO2:40ppm;N2:10ppm
                          var semiSplitA = a.split(';');
                          var semiSplitB = b.split(';');
                          if (semiSplitA.length > 1 && semiSplitB.length > 1) {
                              var colonSplitA = semiSplitA[0].split(':');
                              var gasName = colonSplitA[0];
                              var concerA = colonSplitA[1].substring(0, colonSplitA[1].indexOf("ppm"));
                              for (var i = 0; i < semiSplitB.length; i++) {
                                  var colonSplitB = semiSplitB[i].split(':');
                                  if (colonSplitB[0] == gasName) {
                                      var concerB = colonSplitB[1].substring(0, colonSplitB[1].indexOf("ppm"));
                                      return parseFloat(concerA) > parseFloat(concerB) ? 1 : -1;
                                  }
                              }
                          }
                          //没有匹配组分的话就按长度排序
                          return a.length > b.length ? 1 : -1;
                      }
                  },
                  { field: 'BottleVolume', title: '规格（L）', align: "center", width: 60 },
                  {
                      field: 'IsNewBottle', title: '是否新瓶', align: "center", width: 60,
                      formatter: function (value, row, Index) {
                          return com.getArrayText(StaticCombo.isNewBottle, value);
                      }
                  },
                 {
                     field: 'OrderCount', title: '订货数量', align: "center", width: 60
                 },
                 {
                     field: 'InMakingCount', title: '在制数量', align: "center", width: 60
                 },
                {
                    field: 'CompletedCount', title: '配气数量', align: "center", width: 60
                },
                {
                    field: 'QulifiedCount', title: '合格数量', align: "center", width: 60
                },
                {
                    field: 'UnQulifiedCount', title: '不合格数', align: "center", width: 60,
                    styler: function (value, row, index) {
                        if (value > 0) {
                            return 'background-color:red;color:black';
                        }
                    }
                },
                {
                    field: 'StorageCount', title: '入库数量', align: "center", width: 60
                },
                {
                    field: 'DeliveredCount', title: '发货数量', align: "center", width: 60
                },
                {
                    field: 'Note', title: '备注', align: "center", width: 100
                },

                 {
                     field: 'ContractCode', title: '合同编号', align: "center", width: 100
                 }
                ]],
                onDblClickRow: function (rowIndex, rowData) {
                    com.ajax({
                        url: "/Logic/PM/ProductOrderAjax.aspx?method=CheckCommissionValid",
                        data: { detailID: rowData.QuotationDetailID },
                        success: function (data) {
                            if (data == true) {
                                top.wrapper.addTab("绑定气瓶", "/UI/PM/BindBottle.aspx?action=edit&QuotDetailID=" + rowData.QuotationDetailID + "&ProdOrderID=" + rowData.ProductOrderID)
                            }
                            else {
                                com.message("error", "当前产品已经全部投产或完成，无法再绑定新的气瓶");
                                $("#tbList").datagrid("reload");
                                $("#tbList").datagrid("clearSelections");
                                return
                            }
                        }
                    });
                },
                onLoadSuccess: function (data) {
                    com.mergeCells("tbList", "ProductOrderCode,ComName,IsComplete,IsUrgent,ContractCode,OrderDate,ReleaseDate")
                },
                rowStyler: function (index, row) {
                    if (row.CompletedCount + row.QulifiedCount + row.StorageCount + row.DeliveredCount >= row.OrderCount) {
                        return 'background-color:#00EC00';
                    }
                }
            });

        });

    </script>

    <script type="text/javascript">
        editRow = undefined;
        editAction = undefined;


        //查询
        function funcSearch() {
            var para = com.serializeSearchArray("form1");
            $("#tbList").datagrid("load", para);
            editRow = undefined;
            editAction = undefined;
        }


        //重置
        function funcReload() {
            $("#form1").form("reset");
            var para = com.serializeSearchArray("form1");
            $("#tbList").datagrid("load", para);
            editRow = undefined;
            editAction = undefined;
        }

        //绑定气瓶
        function funcBindBottle() {
            var row = $('#tbList').datagrid('getSelected');
            if (row) {
                com.ajax({
                    url: "/Logic/PM/ProductOrderAjax.aspx?method=CheckCommissionValid",
                    data: { detailID: row.QuotationDetailID },
                    success: function (data) {
                        if (data == true) {
                            top.wrapper.addTab("绑定气瓶", "/UI/PM/BindBottle.aspx?action=edit&QuotDetailID=" + row.QuotationDetailID + "&ProdOrderID=" + row.ProductOrderID)
                        }
                        else {
                            com.message("error", "当前产品已经全部投产或完成，无法再绑定新的气瓶");
                            $("#tbList").datagrid("reload");
                            $("#tbList").datagrid("clearSelections");
                            return
                        }
                    }
                });
            }
            else {
                com.message("information", "请选中一行");
            }
        }
    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="divTotal" style="height: 100%; width: 100%">

        <div id="master" class="container_16" style="height: auto">
            <form id="form1">
                <div class="grid_2 sealbl" style="text-align: right;">
                    是否紧急 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" class="easyui-combobox" id="IsUrgent" name="IsUrgent" data-cp="=" data-options="valueField:'value',textField:'text',data:StaticCombo.isOrderUrgentQuery,panelHeight:'auto'" />
                </div>

                <div class="grid_2 sealbl" style="width: 100px">
                    生产订单号 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="ProductOrderCode" name="ProductOrderCode" data-cp="co" />
                </div>
                <div class="grid_2 sealbl" style="text-align: right;">
                    客户名称 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" class="easyui-combobox" id="ComName" name="ComName" data-cp="=" data-options="valueField:'text',textField:'text',url:'/Logic/BD/CompanyAjax.aspx?method=GetAllCompanyNameList',panelHeight:'auto'" />
                </div>
                <div class="grid_2 sealbl" style="text-align: right;">
                    产品名称 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="ProductName" name="ProductName" data-cp="co" />
                </div>


                <div class="Clear"></div>
                <div class="grid_2 sealbl" style="width: 100px">
                    下单日期从:
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="startOrderDate" name="startOrderDate" data-cp="str>=" class="easyui-datebox" />
                </div>
                <div class="grid_2 sealbl">
                    到:
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="endOrderDate" name="endOrderDate" data-cp="str<=" class="easyui-datebox" />
                </div>
                <%-- <div class="grid_2 sealbl" style="width: 100px">
                    交货日期从:
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="startReleaseDate" name="startReleaseDate" data-cp="str>=" class="easyui-datebox" />
                </div>
                <div class="grid_2 sealbl">
                    到:
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="endReleaseDate" name="endReleaseDate" data-cp="str<=" class="easyui-datebox" />
                </div>--%>
                <div class="grid_2 sealbl" style="text-align: right;">
                    是否完成 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" class="easyui-combobox" id="IsComplete" name="IsComplete" data-cp="="
                        data-options="valueField:'value',textField:'text',
                        data:[{ value:'', text: '全部' },{ value: '0', text: '未完成' }, { value: '1', text: '已完成' }],panelHeight:'auto'" />
                </div>
                <div class="grid_2 sealbl" style="text-align: right;">
                    技术参数 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="TechParams" name="TechParams" data-cp="co" />
                </div>
                <div class="Clear"></div>
                <div class="grid_2 sealbl" style="text-align: right;">
                    气瓶规格 :
                </div>
                <div class="grid_2 seaval" style="text-align: left;">
                    <input type="text" id="BottleVolume" name="BottleVolume" data-cp="=" />
                </div>

            </form>
        </div>
        <table id="tbList" title="产品细则表 " style="width: 100%">
        </table>
    </div>
</asp:Content>
